<template>
    <div>
        <el-table :data="datas.slice((currentPage-1)*pageSize,currentPage*pageSize)" style="width: 100%" max-height="400" border>
            <el-table-column fixed label="序号" width="150">
                <template #default="scopes">
                    {{ scopes.$index+1 }}
                </template>
            </el-table-column>
            <el-table-column fixed prop="directparty" label="党支部名" width="150" />
            <el-table-column fixed prop="middelnum" label="党支中层干部实际人数" width="200" />
            <el-table-column prop="mvotenum" label="党支中层干部已投票人数" width="150" />
            <el-table-column prop="mrate" label="中层投票比例" width="200" disabled/>
            <el-table-column prop="ordinarynum" label="党支普通员工数量" width="150" />
            <el-table-column prop="ovotenum" label="党支已投票员工数量" width="200" disabled/>
            <el-table-column prop="orate" label="员工投票比例" width="200" disabled/>
        </el-table>
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[5, 10, 20, 50]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>
    </div>

</template>
<script setup>
import { get,post } from '@/utils/request.js'
import {ElMessage} from 'element-plus'
import router from '@/router'
import { ref,onMounted } from 'vue'
import {userStore} from '@/stores/counter.js'
import {Upload} from '@element-plus/icons-vue'
import moment from 'moment'

const importDisabled=ref(false)
const store=userStore()
const datas=ref([])
const currentPage=ref(1)
const pageSize=ref(5)
const total=ref(10)

get('/votedata',(message)=>{
console.log(message)
for(let i=0;i<message.length;i++){
message[i].mrate=(message[i].mrate*100).toFixed(2)+"%"
message[i].orate=(message[i].orate*100).toFixed(2)+"%"
}
total.value=message.length
datas.value=message
},(message)=>{
ElMessage.warning(message)
})

const handleSizeChange=(val)=> {
          pageSize.value=val
        console.log(`每页 ${val} 条`);
      }
const handleCurrentChange=(val)=> {
      currentPage.value=val
       console.log(`当前页: ${val}`);
      }
</script>
<style scoped>
</style>